﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Simulation
{
	public partial class F_BSKS: Form
	{
		F_SETT ST	= new F_SETT();
		private string INI = ".\\KEYS.ini";

		int[,] SKEY;

		public F_BSKS()
		{
			InitializeComponent();

			CopyGPKOnGrid();
			CopyLEAPonTB();
		}

		public void CopyGPKOnGrid()
		{
			SKEY = new int[ST.SPID, ST.SKEY];

			for ( int p = 0; p < ST.OSPID; p++ )
			{
				DG_KEYS.Rows.Add( 1 );
				DG_KEYS[0, p].Value = p.ToString();

				StringBuilder S_rslt = new StringBuilder( 512 );
				C_INIF.GetPrivateProfileString( "SEF", p.ToString(), "error", S_rslt, 512, INI );

				string[] token = S_rslt.ToString().Split('-');

				try
				{
					for ( int k = 0; k < ST.OSKEY; k++ )
					{
						OSKEY[p, k] = int.Parse ( token[k] );
						DG_KEYS[k+1, p].Value = token[k];
					}
				}
				catch
				{
					break;
				}
			}
		}

		public int[,] OSKEY
		{
			get { return SKEY; }
			set { SKEY = value; }
		}

		public void CopyLEAPonTB()
		{
			StringBuilder S_rslt = new StringBuilder( 16 );
			C_INIF.GetPrivateProfileString( "LEAP", "INDK", "error", S_rslt, 16, INI );
			TB_INDK.Text = S_rslt.ToString();
			C_INIF.GetPrivateProfileString( "LEAP", "PRWK", "error", S_rslt, 16, INI );
			TB_PRWK.Text = S_rslt.ToString();
			C_INIF.GetPrivateProfileString( "LEAP", "CLSK", "error", S_rslt, 16, INI );
			TB_CLSK.Text = S_rslt.ToString();
			C_INIF.GetPrivateProfileString( "LEAP", "GRPK", "error", S_rslt, 16, INI );
			TB_GRPK.Text = S_rslt.ToString();
		}
	}
}
